<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>我的用户列表</title>

</head>
<body>
<jsp:include page="/incloud/header.jsp"/>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <jsp:include page="/incloud/sidebar.jsp"/>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">我的关注列表</h2>
            </div>
        </div>
        <section class="no-padding-bottom">

            <div class="list-group myList">
                <c:forEach items="${focusList.data}" var="user">
                    <ul>
                        <li class="list-group-item">
                            <a href="user_detail.jsp">${user.realName}</a>
                            <div style="float: right" class="text-right">
                                <input type="submit" class="btn btn-danger" value="取消关注"
                                       id="isFocus" onclick="delFocus(${user.id})">
                            </div>
                        </li>
                    </ul>

                </c:forEach>
                <nav class="text-center" aria-label="Page navigation">
                    <ul class="pagination">
                        <li>
                            <a href="#" aria-label="Previous" onclick="pre()">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <c:forEach begin="1" end="${focusList.totalPage}" varStatus="row">
                            <li><a  ${row.count == focusList.currPage?'style="background: #0c5460"':'' }
                                    href="/internal/findPageFocus?currPage=${row.count}&realName=${realName}">${row.count}</a>
                            </li>
                        </c:forEach>
                        <li>
                            <a href="#" aria-label="Next" onclick="next()">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        </section>

        <jsp:include page="/incloud/footer.jsp"/>
    </div>
</div>


</body>
</html>
<script>
    function delFocus(userId) {
        $.post("/internal/focus", {"userId": userId}, function (res) {
            if (res == "1"){
                layer.msg("取消关注")
            }
            location.reload();
        })

    }
</script>
<script>
    function pre() {
        if (${focusList.currPage-1<=0}) {
            layer.msg("已经是第一页了")
            return;
        }
        window.location.href = "/internal/findPageFocus?currPage=${focusList.currPage - 1}&realName=${realName}"
    }

    function next() {
        if (${focusList.currPage+1 > focusList.totalPage}) {
            layer.msg("已经是最后一页了")
            return;
        }
        window.location.href = "/internal/findPageFocus?currPage=${focusList.currPage + 1}&realName=${realName}"
    }
</script>